package com.yuheadline.article.scheduler;

import com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper;
import com.yuheadline.article.mapper.ArticleMapper;
import com.yuheadline.model.article.domain.Article;
import lombok.RequiredArgsConstructor;
import org.springframework.scheduling.annotation.Scheduled;
import org.springframework.stereotype.Component;

@Component
@RequiredArgsConstructor
public class ScheduledTasks {
    private final ArticleMapper articleMapper;

    @Scheduled(cron = "0 */10 * * * ?")
    public void cronTask() {
        System.out.println("定时任务执行：清楚文章的tempId~");
        articleMapper.update(new LambdaUpdateWrapper<Article>().isNotNull(Article::getTempId).set(Article::getTempId, null));
    }
}